fix(settings): start watchdog on cold-enable from the React UI (#9125) - #10287
Merged
Conversation
…#9125) The React Settings "Enable Watchdog" master toggle only ever writes the idle/busy flags; watchdog_enabled is vestigial in that UI. The live start/stop decision in UpdateSettingsEndpoint keyed off the raw, stale watchdog_enabled request field, so a cold enable (idle/busy=true, watchdog_enabled=false) called StopWatchdog() and the watchdog stayed stopped until the next restart - at which point startup re-derived it from the idle flag. Net: enabling the watchdog appeared to do nothing. Derive the run-state from idle||busy as the single source of truth, mirroring the startup invariant: - ApplyRuntimeSettings now sets WatchDog = idle||busy whenever either field is present (so a full disable also brings it down), while an API client posting only watchdog_enabled keeps its explicit value. - Add ApplicationConfig.WatchdogShouldRun() mirroring startWatchdog's gating (idle/busy, LRU eviction, memory reclaimer); the /api/settings handler uses it to decide start vs stop. - Belt-and-suspenders: the Settings.jsx master toggle also writes watchdog_enabled = idle||busy. Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re: #9125
The original v4.0.0 "settings don't save" report is already resolved (settings persist to
runtime_settings.jsonacross reload + restart). This fixes a residual bug found while verifying: enabling the watchdog from a cold (off) state via the React Settings master toggle did nothing until the next server restart.Root cause
UpdateSettingsEndpoint(core/http/endpoints/localai/settings.go:226) keyed its live start/stop decision off the raw request fieldwatchdog_enabled. The React master toggle only writeswatchdog_idle_enabled/watchdog_busy_enabled;watchdog_enabledis vestigial and loads stale asfalse. So a cold-enable POST carriedwatchdog_enabled=false, the handler calledStopWatchdog()(a no-op), and the watchdog never started until restart re-derived it from the idle flag.Fix
ApplyRuntimeSettingsnow deriveso.WatchDog = idle || busywhenever either field is present (also fixes the disable direction).WatchdogShouldRun()mirrorsstartWatchdog's gating; the settings handler uses it instead of the rawwatchdog_enabled.watchdog_enabled = idle||busy.Test plan
core/config/application_config_test.go: cold-enable, disable-both, and explicit-watchdog_enabledbackward-compat specs.core/http/endpoints/localai/settings_test.go: HTTP spec asserting the live watchdog is non-nil after a cold-enable POST (red → green).go test ./core/config/... ./core/http/endpoints/localai/...green; scoped lint clean.Assisted-by: claude:claude-opus-4-8 [Claude Code]